<form id="form">
  <label>文件<input type="file" name="file" /></label>
  <br />
  <input type="button" value="提交" id="submit" />
</form>

<script>
  const form = document.querySelector("#form");
  submit.onclick = () => {
    // js内置对象
    const formData = new FormData(form);
    // 创建ajax对象
    const xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
      if (this.readyState === 4 && this.status === 200) {
        console.log(this.response);
      }
    };
    xhr.open("post", "http://localhost:3005/uploads");
    xhr.send(formData);
  };
</script>
